var dbconfig = require('../util/dbconfig')

//获取用户信息
getuser = function(req, res, next) {
  // res.render('index', { title: 'Express' });
  var sql="select * from user";
  var sqlArr = [];
  var callBack =(err,data)=>{
    if(err){
      console.log('连接出错了');
    }else{
      res.json({
        "list":data
      })
    }
  }
  dbconfig.sqlConnect(sql,sqlArr,callBack)
}

getpostcate = (req,res)=>{
  let id =req.params.id
  var sql = "select * from post where cate_id=?"
  var sqlArr=[id]
  var callBack =(err,data)=>{
    if(err){
      console.log('连接出错了');
    }else{
      res.json({
        "list":data
      })
    }
  }
  dbconfig.sqlConnect(sql,sqlArr,callBack)
}

module.exports={
  getuser,getpostcate
}